#include "../engine/GameObject.h"
#include "../shared/utils.h"
#include "RenderableUnitImp.h"
#include <cassert>
#include <string>

namespace Putin{

Vec3f RenderableUnitImpl::getPosition()
{
	const Vec3f& u = mObj->getPosition();
	return Vec3f(u.x,u.z,u.y);
}

Vec3f RenderableUnitImpl::getFacingDirection()
{
	const Vec3f& u = mObj->getFacingDirection();
	return Vec3f(u.x,u.z,u.y);
}

Vec3f RenderableUnitImpl::getChildDirection()
{
	const Vec3f& u = mObj->getChildFacingDirection();
	return Vec3f(u.x,u.z,u.y);
}

bool RenderableUnitImpl::hasChild()
{
	bool ret= getChildMesh() != "";
	return ret;
}

Vec3f RenderableUnitImpl::getUpVector()
{
	const Vec3f& u = mObj->getUpVector();
	return Vec3f(u.x,u.z,u.y);
}

std::string RenderableUnitImpl::getId()
{
	return Utils::intToString(mObj->getID());
}

std::string RenderableUnitImpl::getMesh()
{
	return mObj->getMesh();
}

std::string RenderableUnitImpl::getMaterial()
{
	return mObj->getMaterial();
}

std::string RenderableUnitImpl::getChildMesh()
{
	return mObj->getChildMesh();
}

std::string RenderableUnitImpl::getChildMaterial()
{
	return mObj->getChildMaterial();
}

void RenderableUnitImpl::setId(std::string id)
{
	//mObj->mId = id;
	assert(0);
}

std::vector< std::string > RenderableUnitImpl::getParticleEffects()
{
	return this->mObj->mEffectList;
}

void RenderableUnitImpl::setPosition( Vec3f position )
{
	//TODO: SHOULD NOOOOOT BE USED!!??
	assert(0);
}

void RenderableUnitImpl::setFacingDirection( Vec3f facingDirection )
{
	//TODO: SHOULD NOOOOOT BE USED!!??
	assert(0);
}

void RenderableUnitImpl::setUpVector( Vec3f upVector )
{
	//TODO: SHOULD NOOOOOT BE USED!!??
	assert(0);
}
void RenderableUnitImpl::setMesh( const std::string& mesh )
{
	mObj->mMesh = mesh;
}

void RenderableUnitImpl::setMesh()
{
	setMesh("putin/tank");
}

void RenderableUnitImpl::setMaterial( const std::string& material )
{
	mObj->mMaterial = material;
}

void RenderableUnitImpl::addParticleEffect( const std::string& effect )
{
	//TODO: Dunno
	mObj->mEffectList.push_back(effect);
}

void RenderableUnitImpl::removeParticleEffect( const std::string& effect )
{
	//TODO: dunno
	for( std::vector<std::string>::iterator i = mObj->mEffectList.begin();
		i != mObj->mEffectList.end(); i++)
	{
		if( (*i) == effect ) 
		{
			mObj->mEffectList.erase(i);
			break;
		}
	}
	
}

bool RenderableUnitImpl::hasParticleEffect( void )
{
	return !mObj->mEffectList.empty();
	return true;
}

}